#include "Patron.h"

namespace Books{

	Patron::Patron(string name, int number, int init_debt) 
		:reader_name(name), reader_card_num(number), reader_debt(init_debt)
	{
		if (number <=0 || init_debt <0) 
			throw my_err::Error("Incorrect reader data!");
	}

	void Patron::assume_paid(int summ)
	{
		if (reader_debt < summ)
			throw my_err::Error("Too big paid");
		reader_debt -=summ;
	}

	bool have_debt(const Patron& p)
	{
		return (p.get_curr_debt() > 0);
	}

	bool operator == (const Patron& p1, const Patron& p2)
	{
		return (p1.get_number()==p2.get_number());
	}


	std::ostream& operator << (std::ostream& out, const Patron& p)
	{
		return out << p.get_number() << '\t' << p.get_name() << std::endl;
	}
}